#ifndef _FE_LOG_
#define _FE_LOG_

#include <stdio.h>
#include <time.h>
/**This is a singliton class for logger the information of fe_app
 *
 */
class felogger
{
	
	private:
		FILE* _logFile; 
		felogger(const char* logfile);
	public:
		bool log(const char *msg);
		static felogger* singleInstance;
		static felogger* getInstance();
		~felogger();	
};
/** Get the single instance of the logger
 *
 *
 */
felogger* felogger::getInstance()
{
	if(singleInstance==NULL)
		singleInstance=new felogger("FE_APP.LOG");
	return singleInstance;
}
/** constructor
 *
 *
 */
felogger::felogger(const char *fileName)
{
	_logFile=fopen(fileName,"a+");	
}
/**destroyer
 *
 *
 */
felogger::~felogger()
{
	fclose(_logFile);
	if(singleInstance!=NULL)
		delete singleInstance;
}
/**log information to the file
 *
 *
 */
bool felogger::log(const char *msg)
{
	if(msg==NULL || ferror(_logFile))
		return false;
	//get the current time
	time_t now;
	time(&now);
	fprintf(_logFile,"%s %s\n",ctime(&now),msg);
	return true;
}
felogger *felogger::singleInstance=NULL;
#endif
